package com.zmn.plat.services.impl.extension.serv.category;

import java.util.Date;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.zmn.plat.model.entity.extension.serv.category.ExtensionServCategory;
import com.zmn.plat.model.entity.extension.serv.category.ExtensionServCategoryQuery;
import com.zmn.plat.model.vo.extension.serv.category.ExtensionServCategoryVO;
import com.zmn.plat.persistence.interfaces.extension.serv.category.ExtensionServCategoryDao;
import com.zmn.plat.services.interfaces.extension.serv.category.ExtensionServCategoryService;

@Service
public class ExtensionServCategoryServiceImpl implements ExtensionServCategoryService {

    @Resource
    ExtensionServCategoryDao extensionServCategoryDao;

    @Override
    public ExtensionServCategory findByKey(Integer categId) {
        return extensionServCategoryDao.findByKey(categId);
    }

    @Override
    public List<ExtensionServCategoryVO> listPageByQuery(ExtensionServCategoryQuery query) {
        int count = countByQuery(query);
        query.setTotalCount(count);
        return extensionServCategoryDao.listPageByQuery(query);
    }

    @Override
    public List<ExtensionServCategory> listByQuery(ExtensionServCategoryQuery query) {
        return extensionServCategoryDao.listByQuery(query);
    }

    @Override
    public List<ExtensionServCategory> listAll() {
        return extensionServCategoryDao.listAll();
    }

    @Override
    public Integer countByQuery(ExtensionServCategoryQuery query) {
        return extensionServCategoryDao.countByQuery(query);
    }

    @Override
    public Integer updateStatusByKey(ExtensionServCategory extensionServCategory) {
        return extensionServCategoryDao.updateStatusByKey(extensionServCategory);
    }

    @Override
    public Integer updateStatusBatchByKey(List<Integer> ids, Integer status, String mcStaffName) {
        return extensionServCategoryDao.updateBatchStatusByKey(ids, status, mcStaffName);
    }

    @Override
    public Integer updateFirstLetterByKey(Integer categId, String firstLetter, String mcStaffRealName) {
        ExtensionServCategory extensionServCategory = new ExtensionServCategory();
        extensionServCategory.setCategId(categId);
        extensionServCategory.setFirstLetter(firstLetter);
        extensionServCategory.setUpdater(mcStaffRealName);
        extensionServCategory.setUpdateTime(new Date());
        return extensionServCategoryDao.updateFirstLetterByKey(extensionServCategory);
    }

    @Override
    public Integer updateSortByKey(ExtensionServCategory extensionServCategory) {
        return extensionServCategoryDao.updateSortByKey(extensionServCategory);
    }

    @Override
    public Integer updateSortByKey(Integer categId, Integer sort, String mcStaffName) {
        ExtensionServCategory extensionServCategory = new ExtensionServCategory();
        extensionServCategory.setCategId(categId);
        extensionServCategory.setSort(sort);
        extensionServCategory.setUpdater(mcStaffName);
        extensionServCategory.setUpdateTime(new Date());

        return updateSortByKey(extensionServCategory);
    }

    @Override
    public Integer updateByKey(ExtensionServCategory extensionServCategory) {
        return extensionServCategoryDao.updateByKey(extensionServCategory);
    }

    @Override
    public Integer insert(ExtensionServCategory extensionServCategory) {
        return extensionServCategoryDao.insert(extensionServCategory);
    }

    @Override
    public Integer deleteByKey(Integer categId) {
        return extensionServCategoryDao.deleteByKey(categId);
    }

}